package com.jonwa.dansRPG.skills;

import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.*;
import org.bukkit.util.Vector;

public class FireballSkill implements Skill {

    @Override
    public String getName() {
        return "Fireball";
    }

    @Override
    public int getCooldown() {
        return 5; // 5秒冷却
    }

    @Override
    public void execute(Player caster) {
        // 粒子效果
        caster.getWorld().playSound(caster.getLocation(), Sound.ENTITY_BLAZE_SHOOT, 1.0f, 1.0f);

        // 计算发射方向
        Location spawnLoc = caster.getEyeLocation().add(0, -0.5, 0);
        Vector direction = caster.getEyeLocation().getDirection();

        // 创建火球
        Fireball fireball = caster.getWorld().spawn(spawnLoc, Fireball.class);
        fireball.setDirection(direction);
        fireball.setYield(2.0f); // 爆炸威力
        fireball.setShooter(caster);
        fireball.setVelocity(direction.multiply(1.5)); // 速度

        caster.sendMessage("§6🔥 释放了火球术！");
    }
}